package lunadevs.luna.module.exploits;

import lunadevs.luna.category.Category;
import lunadevs.luna.events.DamageBlockEvent;

import org.lwjgl.input.Keyboard;

import com.darkmagician6.eventapi.EventTarget;

import lunadevs.luna.module.Module;
import net.minecraft.item.ItemBlock;
import net.minecraft.network.play.client.C07PacketPlayerDigging;
import net.minecraft.network.play.client.C08PacketPlayerBlockPlacement;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;

public class NoGhostBlock extends Module{

	public NoGhostBlock() {
		super("NoGhostBlock", Keyboard.KEY_NONE, Category.EXPLOITS, false);
	}
	
	@EventTarget
	public void damageBlock(DamageBlockEvent event) {
		if(!this.isEnabled) return;
		if(!(mc.thePlayer.getHeldItem().getItem() instanceof ItemBlock)) {
			mc.getNetHandler().addToSendQueue(new C08PacketPlayerBlockPlacement(event.getBlockPos(), -1, mc.thePlayer.getCurrentEquippedItem(), 0.0F, 0.0F, 0.0F));
		      mc.thePlayer.sendQueue.addToSendQueue(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.RELEASE_USE_ITEM, new BlockPos(-1, -1, -1), EnumFacing.fromAngle(-1.0D)));
		}
	}
	
	public void onDisable() {
		
	}
	
	public String getValue() {
		return null;
	}
	
}
